<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	$admin=D('admin');
    	$data['username']=I('username');
    	$data['password']=I('password');
    	$data['verify']=I('verify');
    	// dump($_POST);
    	// die;
		if(IS_POST){
			if($admin->create($data,4)){
				if($admin->login()){
					$this->success('登录成功，跳转中...',U('Index/index'));
				}else{
					$this->error('您的用户名或密码错误！');
				}
			}else{
				$this->error($admin->getError());
			}
			
			
			return;
		}
		if(session('id')){
			$this->error('您已经登录该系统，请勿重复登录！',U('Index/index'));
		}else{
			$this->display('login');
		}
    	
    }
	public function verify(){
		$Verify = new \Think\Verify();
		$Verify->codeSet = '0123456789'; //数字验证码
		$Verify->fontSize = 30;
		$Verify->length   = 4;
		$Verify->useNoise = TRUE;
		$Verify->entry();
	}
	
}